# PowerShell script to build and run Unity tests
$ErrorActionPreference = "Stop"

# Compiler settings
$CC = "gcc"
$CFLAGS = "-Wall -Wextra -I./ -I./Unity/src"
$LDFLAGS = ""

# Source files
$SOURCES = @(
    "sxnutils.c",
    "test_sxnutils.c",
    "test_runner.c",
    "Unity/src/unity.c"
)

# Output executable
$OUTPUT = "test_runner.exe"

# Build command
& $CC ($CFLAGS -split ' ') $SOURCES -o $OUTPUT ($LDFLAGS -split ' ')

if ($LASTEXITCODE -ne 0) {
    Write-Error "Compilation failed"
    exit 1
}

# Run tests
Write-Host "Running tests..."
.\$OUTPUT

if ($LASTEXITCODE -ne 0) {
    Write-Error "Some tests failed"
    exit 1
}

Write-Host "All tests passed"
exit 0
